import {store} from '../index'
import {defineStore} from 'pinia'

type CurrentPatientType = {
    patientIdStr?: string //患者ID字符串
    patientName?: string //患者姓名
    visitNoStr?: string //就诊号字符串
    gender?: string //性别
    birthday?: string //出生日期 yyyy-MM-dd
    identityNumber?: string //身份证号
    phone?: string //电话
    age?: string //年龄
    bedNo?: string //床位号
    deptId?: number //科室ID
    diagnosis?: string
    deptName?: string //科室名字
    rentalDays?: number //设备租用天数
    doctorId?: number //主治医生ID
    doctorName?: string //主治医生名字
    chronicDisease?: string | Array<string> //慢性疾病 多种疾病，英文逗号隔开 '',''
    province?: string //省
    city?: string //市
    district?: string //区
    address?: string //详细地址
    hospitalName?: string //详细地址
}
type reporType = {
    visitNo: StrUn //就诊号
    startTime?: string
}

interface patientState {
    isDays: boolean //是否多天
    currentPatient: CurrentPatientType //当前患者信息
    visitStatus: number //就诊状态
    sleepDays: boolean //睡眠是否多天
    reporQueryParams: reporType //报告请求数据
}

export const usePatientStore = defineStore({
    id: 'patient',
    state: (): patientState => {
        return {
            visitStatus: 0,
            isDays: true,
            currentPatient: {},
            sleepDays: true,
            reporQueryParams: {visitNo: '', startTime: ''}
        }
    },
    getters: {},
    actions: {
        setIsDays(boolean: boolean) {
            this.isDays = boolean
        },
        setVisitStatus(state: number) {
            this.visitStatus = state
        },
        setCurrentPatient(data: CurrentPatientType) {
            this.currentPatient = data
        },
        setReporQueryParams(data: reporType) {
            this.reporQueryParams = data
        },
        //获取就诊记录
        setSleepDats(boolean: boolean) {
            this.sleepDays = boolean
        }
    }
})

export const usePatientStoreWithOut = () => {
    return usePatientStore(store)
}
